package com.pshare.artemis.common.enums;

/**
 * 由于某个动作导致的订单关闭
 */
public enum CloseReason {

	BUYER_PAY_TIMEOUT(1, "超时未付款被关闭"), SELLER_CONFIRM_TIMEOUT(2, "超时未接单被关闭"), BY_SELLER(3, "卖家关闭交易"), REFUND_COMPLETE(4,
			"完成退款"), REFUSED_REFUND(5, "卖家拒绝退款"), REFUND_TIMEOUT(6, "超时自动退款"), BY_CMS(7, "客服关闭交易"), BY_GUEST(8,
			"买家关闭交易");

	private CloseReason(int code, String name) {
		this.code = code;
		this.name = name;
	}

	private int code;
	private String name;

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public static String getName(int code) {
		for (CloseReason closeReason : CloseReason.values()) {
			if (closeReason.getCode() == code) {
				return closeReason.getName();
			}
		}
		return "";
	}

}
